# import logging
# from flask import Blueprint,request,jsonify
# import gevent as sg

# import eventlet
# import eventlet.hubs.epolls
# import eventlet.hubs.kqueue
# import eventlet.hubs.selects
# import dns
# import dns.dnssec
# import dns.e164
# import dns.hash
# import dns.namedict
# import dns.tsigkeyring
# import dns.update
# import dns.version
# import dns.zone
from engineio.async_drivers import gevent
from flask_socketio import SocketIO, emit

# app = Blueprint(__name__,__name__)



# @socketio.on('connect', namespace='/test_conn')
# def test_connect():
#     while True:
#         socketio.sleep(5)
#         t = random_int_list(1, 100, 10)
#         socketio.emit('server_response',
#                       {'data': t},
#                       namespace='/test_conn')

_socketio=None

def init(app):
    global _socketio
    _socketio = SocketIO(app,async_mode='gevent')
    return _socketio

def emit(type,msg={}):
    _socketio.emit(type,msg,namespace='/ws')